package cn.xiuxius.embedded.runconfig.ui;

import cn.xiuxius.embedded.runconfig.EasySTCRunConfigurationOptions;
import com.intellij.ui.components.JBCheckBox;
import com.intellij.util.ui.FormBuilder;
import org.jetbrains.annotations.NotNull;

import javax.swing.*;

public class BuildTaskPanel implements TaskSettingsPanel {
    private final JBCheckBox cleanCheckBox = new JBCheckBox("Clean before build");
    private final JPanel panel;

    public BuildTaskPanel() {
        panel = FormBuilder.createFormBuilder()
                .addComponent(cleanCheckBox)
                .getPanel();
    }

    @Override
    public @NotNull JPanel getComponent() {
        return panel;
    }

    @Override
    public void resetFrom(@NotNull EasySTCRunConfigurationOptions options) {
        cleanCheckBox.setSelected(options.isBuildClean());
    }

    @Override
    public void applyTo(@NotNull EasySTCRunConfigurationOptions options) {
        options.setBuildClean(cleanCheckBox.isSelected());
    }
}
